var isAndroid = false; var isIOS = false; if( /Android|webOS|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) { var isAndroid = true; } if((navigator.userAgent.match(/iPad/i))){ ///console.log('Ipad'); isIphone = false; isIos = true; }else if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i))){ isIphone = true; isIos = true; } window.onload = function(e) { style = document.createElement('style'); style.innerHTML = '.adrequest-iframe-wrapper{position: relative;padding-bottom: 56.25%;padding-top: 0px;height: 0;} .adrequest-iframe-wrapper iframe, .iframe-wrapper iframe {position: absolute; top: 0; left: 0;width: 100%;height: 100%;}'; document.getElementsByTagName('head')[0].appendChild(style) iframes = document.getElementsByTagName('iframe'); for (i = 0; i < iframes.length; i++) { iframe = iframes[i]; yid = matchYoutube(iframe.src); if(yid != ''){ iframe.setAttribute('id', 'temp-'+ yid) frame = document.createElement('iframe'); if(isIOS || isAndroid){ mobile = true; }else { mobile = false; } //document.getElementsBy div = document.createElement('div'); div.setAttribute('class', 'adrequest-iframe-wrapper'); div.appendChild(frame); frame.setAttribute('width', '100%'); frame.setAttribute('height', '100%'); frame.setAttribute('frameborder', 0); frame.setAttribute('allowfullscreen', true); frame.setAttribute('mozallowfullscreen', true); frame.setAttribute('webkitallowfullscreen', true); frame.setAttribute('scrolling', 'no'); frame.setAttribute('src', '//player.videoadvertentie.com/y/'+yid+'/'+LicenseCode.code+'/?mobile='+mobile+'&ref='+window.location.href+'&random='+Math.random()); iframe.parentNode.insertBefore(div, iframe); iframe.parentNode.removeChild(iframe); } } } function matchYoutube(url){ if(url != undefined){ var p = /^.*(?:(?:youtu\.be\/|v\/|vi\/|u\/\w\/|embed\/)|(?:(?:watch)?\?v(?:i)?=|\&v(?:i)?=))([^#\&\?]*).*/; if(url.match(p)){ //console.log(url.match(p)[1]); yid = url.match(p)[1]; if(yid.match(/[a-zA-Z0-9_-]{11}/)){ return yid; }else{ return false; } //return url.match(p)[1]; } var p = /^(\/\/)(?:www\.)?(?:youtu\.be\/|youtube\.com\/(?:embed\/|v\/|watch\?v=|watch\?.+&v=))((\w|-){11})(?:\S+)?jQuery/; if(url.match(p)){ return url.match(p)[2]; } return false; }else{ return false; } }